package ua.net.gm.server.primitives;

import java.util.Objects;

/**
 *
 * @author Yason
 */
public class Rectangle
{
    private Point position;
    
    private Size size;

    public Rectangle(Point position, Size size)
    {
        this.position = position;
        this.size = size;
    }

    public Rectangle(int x, int y, int w, int h)
    {
        this(new Point(x, y), new Size(w, h));
    }

    @Override
    public String toString()
    {
        return "Rectangle{" + "a=" + position + ", b=" + size + '}';
    }

    @Override
    public int hashCode()
    {
        int hash = 5;
        hash = 67 * hash + Objects.hashCode(this.position);
        hash = 67 * hash + Objects.hashCode(this.size);
        return hash;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (obj == null)
        {
            return false;
        }
        if (getClass() != obj.getClass())
        {
            return false;
        }
        final Rectangle other = (Rectangle) obj;
        return Objects.equals(this.position, other.position) && Objects.equals(this.size, other.size);
    }

    public Point getPosition()
    {
        return position;
    }
    
    public int getX()
    {
        return position.getX();
    }
    
    public int getY()
    {
        return position.getY();
    }
    
    public int getHeight()
    {
        return size.getHeight();
    }

    public int getWidth()
    {
        return size.getWidth();
    }
    
    public Size getSize()
    {
        return size;
    }
}
